<!DOCTYPE html>
<html lang="zh" xmlns:th="http://www.thymeleaf.org" th:with="title='商品分类管理',active='cate'">
<head th:replace="/manage/header::headerFragment(title,active)"></head>
<body>
<div th:replace="/manage/header::header-body"></div>

<div class="row">
  <div class="col-2">
    <div th:replace="/manage/leftnav::leftnav"></div>
  </div>

  <div class="col-10">
    <form role="form" action="/travelType/submitUpdateTravelNotesType" method="post" onsubmit="return validateForm()">
      <div class="form-group">
        <input type="hidden" class="form-control" id="type_id" name="type_id" th:value="${travelNotesType.type_id}">
        <label for="type_name" class="col-sm-2 control-label">
          游记分类名称
        </label>
        <div class="col-sm-10">
          <input type="text" class="form-control" id="type_name" placeholder="请输入游记分类名称"
                 th:value="${travelNotesType.type_name}"
                 name="type_name" />
        </div>
      </div>

      <div class="mb-3 mt-3">
        <label for="type_describe" class="col-sm-2 control-label">分类描述</label>
        <input type="text" class="form-control" id="type_describe"
               th:value="${travelNotesType.type_describe}"
               name="type_describe" placeholder="请输入分类描述"/>
      </div>

      <button type="submit" class="btn btn-primary">提交</button>
    </form>
  </div>
</div>

<script>
  function validateForm() {
    var typeName = document.getElementById("type_name").value.trim();
    var typeDescribe = document.getElementById("type_describe").value.trim();

    if (typeName === "") {
      alert("游记分类名称不能为空");
      return false;
    }

    if (typeDescribe === "") {
      alert("分类描述不能为空");
      return false;
    }

    return true;
  }
</script>

</body>
</html>
